<template include="./view/htm/user_common.header.htm">
	<slot name="body">
        <ul class="threadlist list-unstyled bg-white shadow">
            <!--{hook user_comment_threadlist_before.htm}-->
            <?php if(!empty($arrlist)) { foreach($arrlist as $_post) { ?>
            <li class="media thread bg-white" data-pid="<?php echo $_post['pid'];?>" data-uid="<?php echo $_post['uid'];?>">
                <?php if($_post['allowdelete']) { ?>
                <input type="checkbox" name="pid" class="mt-3 ml-2" value="<?php echo $_post['pid']; ?>" />
                <?php } ?>
                <!--{hook user_comment_list_inc_avatar_after.htm}-->
                <div class="media-body">
                    <div class="message mt-1 break-all ml-2">
                        <!--{hook user_comment_list_inc_subject_before.htm}-->
                        <h6 class="font-weight-bold">
                            <a href="<?php echo url('read-'.$_post['tid']);?>" target="_blank">
                                <?php echo $_post['subject'];?>
                            </a>
                        </h6>
                        <!--{hook user_comment_list_inc_subject_after.htm}-->
                        <!--{hook user_comment_list_inc_message_before.htm}-->
                        <?php echo $_post['message'];?>
                        <!--{hook user_comment_list_inc_message_after.htm}-->
                    </div>
                </div>
            </li>
            <?php }} ?>
            <!--{hook user_comment_threadlist_after.htm}-->
        </ul>
        <?php if($allowdelete) { ?>
        <div class="text-center">
            <label class="mr-3">
                <input type="checkbox" data-target='input[name="pid"]' class="checkall mt-2 mr-2" value="" aria-label="<?php echo lang('checkall');?>" />
                <?php echo lang('checkall');?>
            </label>
            <div class="btn-group mod-button my-3" role="group" aria-label="">
                <!--{hook user_comment_mode_delete_before.htm}-->
                <button class="btn btn-secondary delete" data-href="<?php echo url('comment-delete');?>">
                    <?php echo lang('delete');?>
                </button>
                <!--{hook user_comment_mode_delete_after.htm}-->
            </div>
        </div>
        <?php } ?>
        <?php if ($pagination) { ?>
        <nav class="my-3">
            <ul class="pagination justify-content-center flex-wrap">
                <?php echo $pagination; ?>
            </ul>
        </nav>
        <?php } ?>
	</slot>
</template>
<script>
    var body = $('body');
    body.on('click', 'button.delete', function() {
        var jthis = $(this);
        var pidarr = $('input[name="pid"]').checked();
        var href = jthis.data('href');
        if (window.confirm(lang.confirm_delete)) {
            $.xpost(href, {type:1,pid:pidarr}, function(code, message) {
                if(code == 0) {
                    window.location.reload();
                } else {
                    $.alert(message);
                }
            });
        }
        return false;
    });
$('a[data-active="user-comment"]').addClass('active');
<!--{hook user_comment_js.htm}-->
</script>
<!--{hook user_comment_js_after.htm}-->